package com.softstao.guoyu.mvp.interactor.agent;

import com.softstao.guoyu.global.APIInterface;
import com.softstao.guoyu.model.agent.AgentList;
import com.softstao.guoyu.model.agent.MonthCondition;
import com.softstao.guoyu.model.agent.MonthDetail;
import com.softstao.guoyu.model.agent.MonthOrderList;
import com.softstao.guoyu.model.agent.MonthProList;
import com.softstao.guoyu.model.agent.ParentInfoIndex;
import com.softstao.guoyu.model.agent.ShareInvite;
import com.softstao.guoyu.model.agent.SubApplyList;
import com.softstao.guoyu.model.agent.SubInfo;
import com.softstao.guoyu.model.agent.TeamCount;
import com.softstao.guoyu.model.sale.OrderDetail;
import com.softstao.guoyu.mvp.interactor.BaseInteractor;
import com.softstao.guoyu.utils.MyHttpParams;

import rx.functions.Action1;

/**
 * Created by vaikus on 2017/6/27.
 */

public class AgentInteractor extends BaseInteractor{
    public void getTeamCount(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.TEAM_COUNT)
                .setType(TeamCount.class)
                .getVolley()
                .post(params);
    }

    public void getParentInfo(int agentId,int parentId,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"parentId",parentId);
        builder.setAction(action1)
                .setUrl(APIInterface.PARENT_INFO)
                .setType(ParentInfoIndex.class)
                .getVolley()
                .post(params);
    }

    public void getDirectSub(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.DIRECT_SUB)
                .setType(AgentList.class)
                .getVolley()
                .post(params);
    }

    public void recommendToMe(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.RECOMMEND_TO_ME)
                .setType(AgentList.class)
                .getVolley()
                .post(params);
    }

    public void recommendFromMe(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.RECOMMEND_FROM_ME)
                .setType(AgentList.class)
                .getVolley()
                .post(params);
    }

    public void noOrderMonth(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.NO_ORDER_MONTH)
                .setType(AgentList.class)
                .getVolley()
                .post(params);
    }

    public void getSubInfo(int agentId, int subAgentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"subAgentId",subAgentId);
        builder.setAction(action1)
                .setUrl(APIInterface.SUB_INFO)
                .setType(SubInfo.class)
                .getVolley()
                .post(params);
    }

    public void getMonthDetail(int agentId, String subAgentId, String month, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"subAgentId",subAgentId,"month",month);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTH_DETAIL)
                .setType(MonthDetail.class)
                .getVolley()
                .post(params);
    }

    public void getMonthOrder(int page, MonthCondition condition, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        params.put("pageSize","8");
        params.put("pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTH_ORDER_LIST)
                .setType(MonthOrderList.class)
                .getVolley()
                .post(params);
    }

    public void getMonthOrderDetail(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTH_ORDER_DETAIL)
                .setType(OrderDetail.class)
                .getVolley()
                .post(params);
    }

    public void getMonthPro(int page, MonthCondition condition, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        params.put("pageSize","8");
        params.put("pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTH_PRO_LIST)
                .setType(MonthProList.class)
                .getVolley()
                .post(params);
    }

    public void getAllSub(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.All_SUB)
                .setType(AgentList.class)
                .getVolley()
                .post(params);
    }

    public void getInvite(int agentId,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.GET_INVITE_URL)
                .setType(ShareInvite.class)
                .getVolley()
                .post(params);
    }

    public void getSubApply(int page,int agentId,int state,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"type",state,"pageSize","8","pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.GET_SUB_APPLY)
                .setType(SubApplyList.class)
                .getVolley()
                .post(params);
    }

    public void passAudit(int agentId,int processId,String img,String reason,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"processId",processId,"img",img,"reason",reason);
        builder.setAction(action1)
                .setUrl(APIInterface.PASS_AUDIT)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void rejectAudit(int agentId,int processId,String reason,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"processId",processId,"reason",reason);
        builder.setAction(action1)
                .setUrl(APIInterface.REJECT_AUDIT)
                .setType(null)
                .getVolley()
                .post(params);
    }
}
